package com.example.user.web;

import com.example.common.Ov.QuotaApplicationOv;
import com.example.common.Ov.UserOv;
import com.example.common.entity.Const;
import com.example.common.entity.Rsp;
import com.example.common.util.JWTUtil;
import com.example.user.service.BankServiceImpl;
import com.example.user.service.QuotaServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("quota")
public class QuotaController {

    @Autowired
    QuotaServiceImpl quotaService;

    @Autowired
    BankServiceImpl bankService;

    //获取额度列表
    @GetMapping("/getQuotaList")
    public Rsp getQuotaList(){
        return quotaService.geQuotatList();
    }

    //申请额度
    @PostMapping("/quotaApp")
    public Rsp quotaApp(@RequestHeader("Authorization") String token,@RequestBody QuotaApplicationOv quotaApplicationOv){
        System.out.println(token);
        UserOv userOv = JWTUtil.parserToken(token, Const.PUBLIC_KEY);
        System.out.println(userOv);
        return quotaService.quotaApp(userOv,quotaApplicationOv);
    }


    //-----------------------------------银行卡---------------------------------------

    //获取银行卡信息
    @GetMapping("getCardInfo")
    public Rsp getCardInfo(@RequestHeader("Authorization") String token){
        UserOv userOv = JWTUtil.parserToken(token, Const.PUBLIC_KEY);
        return bankService.getCardInfo(userOv);
    }

}
